(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

concat(leaf, Y) → Y
concat(cons(U, V), Y) → cons(U, concat(V, Y))
lessleaves(X, leaf) → false
lessleaves(leaf, cons(W, Z)) → true
lessleaves(cons(U, V), cons(W, Z)) → lessleaves(concat(U, V), concat(W, Z))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

concat(leaf, Y) → Y [1]
concat(cons(U, V), Y) → cons(U, concat(V, Y)) [1]
lessleaves(X, leaf) → false [1]
lessleaves(leaf, cons(W, Z)) → true [1]
lessleaves(cons(U, V), cons(W, Z)) → lessleaves(concat(U, V), concat(W, Z)) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

concat(leaf, Y) → Y [1]
concat(cons(U, V), Y) → cons(U, concat(V, Y)) [1]
lessleaves(X, leaf) → false [1]
lessleaves(leaf, cons(W, Z)) → true [1]
lessleaves(cons(U, V), cons(W, Z)) → lessleaves(concat(U, V), concat(W, Z)) [1]

The TRS has the following type information:
concat :: leaf:cons → leaf:cons → leaf:cons
leaf :: leaf:cons
cons :: leaf:cons → leaf:cons → leaf:cons
lessleaves :: leaf:cons → leaf:cons → false:true
false :: false:true
true :: false:true

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The transformation into a RNTS is sound, since:

(a) The obligation is a constructor system where every type has a constant constructor,

(b) The following defined symbols do not have to be completely defined, as they can never occur inside other defined symbols:


lessleaves

(c) The following functions are completely defined:

concat

Due to the following rules being added:
none

And the following fresh constants: none

(6) Obligation:

Runtime Complexity Weighted TRS where critical functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

concat(leaf, Y) → Y [1]
concat(cons(U, V), Y) → cons(U, concat(V, Y)) [1]
lessleaves(X, leaf) → false [1]
lessleaves(leaf, cons(W, Z)) → true [1]
lessleaves(cons(U, V), cons(W, Z)) → lessleaves(concat(U, V), concat(W, Z)) [1]

The TRS has the following type information:
concat :: leaf:cons → leaf:cons → leaf:cons
leaf :: leaf:cons
cons :: leaf:cons → leaf:cons → leaf:cons
lessleaves :: leaf:cons → leaf:cons → false:true
false :: false:true
true :: false:true

Rewrite Strategy: INNERMOST

(7) NarrowingProof (BOTH BOUNDS(ID, ID) transformation)

Narrowed the inner basic terms of all right-hand sides by a single narrowing step.

(8) Obligation:

Runtime Complexity Weighted TRS where critical functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

concat(leaf, Y) → Y [1]
concat(cons(U, V), Y) → cons(U, concat(V, Y)) [1]
lessleaves(X, leaf) → false [1]
lessleaves(leaf, cons(W, Z)) → true [1]
lessleaves(cons(leaf, V), cons(leaf, Z)) → lessleaves(V, Z) [3]
lessleaves(cons(leaf, V), cons(cons(U'', V''), Z)) → lessleaves(V, cons(U'', concat(V'', Z))) [3]
lessleaves(cons(cons(U', V'), V), cons(leaf, Z)) → lessleaves(cons(U', concat(V', V)), Z) [3]
lessleaves(cons(cons(U', V'), V), cons(cons(U1, V1), Z)) → lessleaves(cons(U', concat(V', V)), cons(U1, concat(V1, Z))) [3]

The TRS has the following type information:
concat :: leaf:cons → leaf:cons → leaf:cons
leaf :: leaf:cons
cons :: leaf:cons → leaf:cons → leaf:cons
lessleaves :: leaf:cons → leaf:cons → false:true
false :: false:true
true :: false:true

Rewrite Strategy: INNERMOST

(9) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

leaf => 0
false => 0
true => 1

(10) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ Y :|: z' = Y, Y >= 0, z = 0
concat(z, z') -{ 1 }→ 1 + U + concat(V, Y) :|: z' = Y, Y >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(V, Z) :|: Z >= 0, z = 1 + 0 + V, z' = 1 + 0 + Z, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(V, 1 + U'' + concat(V'', Z)) :|: Z >= 0, z = 1 + 0 + V, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, V >= 0, V'' >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), Z) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + 0 + Z, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), 1 + U1 + concat(V1, Z)) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: X >= 0, z = X, z' = 0

(11) SimplificationProof (BOTH BOUNDS(ID, ID) transformation)

Simplified the RNTS by moving equalities from the constraints into the right-hand sides.

(12) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 1 }→ 1 + U + concat(V, z') :|: z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, 1 + U'' + concat(V'', Z)) :|: Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), z' - 1) :|: z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), 1 + U1 + concat(V1, Z)) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

(13) CpxRntsAnalysisOrderProof (BOTH BOUNDS(ID, ID) transformation)

Found the following analysis order by SCC decomposition:

{ concat }
{ lessleaves }

(14) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 1 }→ 1 + U + concat(V, z') :|: z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, 1 + U'' + concat(V'', Z)) :|: Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), z' - 1) :|: z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), 1 + U1 + concat(V1, Z)) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed: {concat}, {lessleaves}

(15) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed SIZE bound using CoFloCo for: concat
after applying outer abstraction to obtain an ITS,
resulting in: O(n1) with polynomial bound: z + z'

(16) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 1 }→ 1 + U + concat(V, z') :|: z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, 1 + U'' + concat(V'', Z)) :|: Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), z' - 1) :|: z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), 1 + U1 + concat(V1, Z)) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed: {concat}, {lessleaves}
Previous analysis results are:
concat: runtime: ?, size: O(n1) [z + z']

(17) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed RUNTIME bound using CoFloCo for: concat
after applying outer abstraction to obtain an ITS,
resulting in: O(n1) with polynomial bound: 1 + z

(18) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 1 }→ 1 + U + concat(V, z') :|: z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, 1 + U'' + concat(V'', Z)) :|: Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), z' - 1) :|: z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(1 + U' + concat(V', V), 1 + U1 + concat(V1, Z)) :|: z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed: {lessleaves}
Previous analysis results are:
concat: runtime: O(n1) [1 + z], size: O(n1) [z + z']

(19) ResultPropagationProof (UPPER BOUND(ID) transformation)

Applied inner abstraction using the recently inferred runtime/size bounds where possible.

(20) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 2 + V }→ 1 + U + s :|: s >= 0, s <= 1 * V + 1 * z', z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 4 + V'' }→ lessleaves(z - 1, 1 + U'' + s') :|: s' >= 0, s' <= 1 * V'' + 1 * Z, Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 4 + V' }→ lessleaves(1 + U' + s'', z' - 1) :|: s'' >= 0, s'' <= 1 * V' + 1 * V, z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 5 + V' + V1 }→ lessleaves(1 + U' + s1, 1 + U1 + s2) :|: s1 >= 0, s1 <= 1 * V' + 1 * V, s2 >= 0, s2 <= 1 * V1 + 1 * Z, z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed: {lessleaves}
Previous analysis results are:
concat: runtime: O(n1) [1 + z], size: O(n1) [z + z']

(21) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed SIZE bound using KoAT for: lessleaves
after applying outer abstraction to obtain an ITS,
resulting in: O(1) with polynomial bound: 1

(22) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 2 + V }→ 1 + U + s :|: s >= 0, s <= 1 * V + 1 * z', z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 4 + V'' }→ lessleaves(z - 1, 1 + U'' + s') :|: s' >= 0, s' <= 1 * V'' + 1 * Z, Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 4 + V' }→ lessleaves(1 + U' + s'', z' - 1) :|: s'' >= 0, s'' <= 1 * V' + 1 * V, z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 5 + V' + V1 }→ lessleaves(1 + U' + s1, 1 + U1 + s2) :|: s1 >= 0, s1 <= 1 * V' + 1 * V, s2 >= 0, s2 <= 1 * V1 + 1 * Z, z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed: {lessleaves}
Previous analysis results are:
concat: runtime: O(n1) [1 + z], size: O(n1) [z + z']
lessleaves: runtime: ?, size: O(1) [1]

(23) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed RUNTIME bound using KoAT for: lessleaves
after applying outer abstraction to obtain an ITS,
resulting in: O(n2) with polynomial bound: 2 + 2·z·z' + 16·z' + 2·z'2

(24) Obligation:

Complexity RNTS consisting of the following rules:

concat(z, z') -{ 1 }→ z' :|: z' >= 0, z = 0
concat(z, z') -{ 2 + V }→ 1 + U + s :|: s >= 0, s <= 1 * V + 1 * z', z' >= 0, z = 1 + U + V, U >= 0, V >= 0
lessleaves(z, z') -{ 3 }→ lessleaves(z - 1, z' - 1) :|: z' - 1 >= 0, z - 1 >= 0
lessleaves(z, z') -{ 4 + V'' }→ lessleaves(z - 1, 1 + U'' + s') :|: s' >= 0, s' <= 1 * V'' + 1 * Z, Z >= 0, U'' >= 0, z' = 1 + (1 + U'' + V'') + Z, z - 1 >= 0, V'' >= 0
lessleaves(z, z') -{ 4 + V' }→ lessleaves(1 + U' + s'', z' - 1) :|: s'' >= 0, s'' <= 1 * V' + 1 * V, z = 1 + (1 + U' + V') + V, z' - 1 >= 0, U' >= 0, V' >= 0, V >= 0
lessleaves(z, z') -{ 5 + V' + V1 }→ lessleaves(1 + U' + s1, 1 + U1 + s2) :|: s1 >= 0, s1 <= 1 * V' + 1 * V, s2 >= 0, s2 <= 1 * V1 + 1 * Z, z = 1 + (1 + U' + V') + V, Z >= 0, z' = 1 + (1 + U1 + V1) + Z, V1 >= 0, U' >= 0, V' >= 0, U1 >= 0, V >= 0
lessleaves(z, z') -{ 1 }→ 1 :|: Z >= 0, z' = 1 + W + Z, z = 0, W >= 0
lessleaves(z, z') -{ 1 }→ 0 :|: z >= 0, z' = 0

Function symbols to be analyzed:
Previous analysis results are:
concat: runtime: O(n1) [1 + z], size: O(n1) [z + z']
lessleaves: runtime: O(n2) [2 + 2·z·z' + 16·z' + 2·z'2], size: O(1) [1]

(25) FinalProof (EQUIVALENT transformation)

Computed overall runtime complexity

(26) BOUNDS(1, n^2)